package top.sxlai.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import top.sxlai.entity.DTO.ShareDTO;
import top.sxlai.entity.FileWithFolder;
import top.sxlai.service.OpSharefileService;

import java.util.List;
import java.util.Map;

/**
 * @author : sxl
 * @date : 2024/4/22 23:33
 * @Version: 1.0
 */
@RestController
@CrossOrigin
public class ShareController {
    @Autowired
    private OpSharefileService opSharefileService;

    @PostMapping("/createShare")
    public ResponseEntity<Map<String,String>> createShare(@RequestBody ShareDTO shareDTO){
        return  opSharefileService.createShare(shareDTO);
    }

    @GetMapping("/shareCheck/{shareId}")
    public ResponseEntity<Map<String,String>> share(@PathVariable String shareId){
        return opSharefileService.checkShare(shareId);
    }

    @GetMapping("/managementSharing")
    public ResponseEntity<List<FileWithFolder>> managementSharing() throws Exception {
        return opSharefileService.managementSharing();
    }

    @PostMapping("/cancelSharing")
    public ResponseEntity<Map<String,String>> cancelSharing(@RequestBody ShareDTO shareDTO){
        return opSharefileService.cancelSharing(shareDTO);
    }
}
